package crivia.db.p;

import crivia.db.common.SQL;
import crivia.ecp.ECP;
import crivia.ecp.carry.html.X;
import crivia.ecp.common.ECR;

public class SQLCatcher extends ECP {

	@Override
	protected String HTMLBody() {
		if (rpExist("begin")){
			SQL.LastSQLGroupSize = 1000;
			SQL.SQLRecorderBegin();
			return ""+X.A("End", EU(this), ECR.Target_Self);
		} else {
			StringBuilder sss = new StringBuilder();
			String[] ss = SQL.SQLRecorderEnd();
			if (ss.length > 0){
				sss.append("<br/><br/>Last Execute :");
				for (String s : ss){
					sss.append("<br/><br/>").append(s);
				}
			}
			return ""
				+X.A("Begin", EU(this)+"?begin=1"
					, ECR.Target_Self)
				+sss;
		}
	}

	
	public static final String PageKey = "SQLCatcher";
	@Override
	public String pageKey() {return PageKey;}

}
